package Kolekcje;

import java.util.ArrayList;
import java.util.List;

public class Test {
	public static void main(String[] args) {
		String s = "abc[de]f[gh]ij[klmn]o";
		List<String> list = new ArrayList<String>();
		String tmp = "";
		boolean czyDoTmp = false;
		for (char c : s.toCharArray()) {
			switch (c) {
			case '[':
				czyDoTmp = true;
				break;
			case ']':
				czyDoTmp = false;
				list.add(tmp);
				tmp="";
				break;
			default:
				if (czyDoTmp)
					tmp += c;
				break;
			}
		}
		System.out.println(list);

	}

}
